import os.path
from django.conf.urls.defaults import *
from bmproject.bookmarks.views import *
from django.views.generic.simple import direct_to_template
import django.contrib.auth
import django.contrib.syndication
from bmproject import settings
from bookmarks.feeds import *

django.contrib.auth.LOGIN_URL = '/login/'

site_media = os.path.join(
  os.path.dirname(__file__), 'site_media'
)

feeds = {
  'recent': RecentBookmarks,
  'user': UserBookmarks
 }

urlpatterns = patterns('',
  # Browsing
  (r'^$', main_page),
  (r'^popular/$', popular_page),
  (r'^user/(\w+)/$', user_page),
  (r'^tag/([^\s]+)/$', tag_page),
  (r'^tag/$', tag_cloud_page),
  (r'^search/$', search_page),
  (r'^bookmark/(\d+)/$', bookmark_page),
   

  # Admin 
  (r'^admin/', include('django.contrib.admin.urls')),
    

  # Session management
  
  (r'^login/$','django.contrib.auth.views.login'),
  (r'^lyogout/$', logout_page),
  (r'^register/$', register_page),
  (r'^register/success/$', direct_to_template,
    { 'template': 'registration/register_success.html' }),
  (r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
    { 'document_root': site_media }),
    
  # Comments
  (r'^comments/', include('django.contrib.comments.urls.comments')),  

  # Account management
  (r'^save/$', bookmark_save_page),
  (r'^vote/$', bookmark_vote_page),

      
    # Ajax
  (r'^ajax/tag/autocomplete/$', ajax_tag_autocomplete),
        
          
  # Feeds
  (r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict':feeds}),
     
  #Friends
  (r'^friends/(\w+)/$', friends_page),
  (r'^friend/add/$', friend_add),
  (r'^friend/invite/$', friend_invite),
  (r'^friend/accept/(\w+)/$', friend_accept),
)    